package com.foxzzz.binary.search;

public class Solution374 {
    public int guess(int num) {
        if (num == 1702766719)
            return 0;
        else if (num < 1702766719)
            return 1;
        else
            return -1;
    }

    public int guessNumber(int n) {
        int low = 1;
        int high = n;
        int mid = 0;
        while (low <= high) {
            mid = (int) (((long) high + low) / 2);
            int ret = guess(mid);
            if (ret == 0) {
                return mid;
            } else if (ret == -1) {
                high = mid - 1;
            } else if (ret == 1) {
                low = mid + 1;
            }

        }
        return mid;
    }

    public static void main(String[] args) {
        System.out.println(new Solution374().guessNumber(2126753390));
    }
}
